<template>
  <div>
    <TopFilter :list="topFilterList" :cols="3" labelWidth="110" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>
    <FilterTable
      ref="table"
      selectionType="multiple"
      :columns="columns"
      :datakey="'rows'"
      :fetchapi="fetchApi"
      :params="fetchParams"
      height="260"
      :isColumnFilter="false"
      :isToperInfo="false"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="onRowSelectChange"
    >
    </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button size="small" @click="closeDialog">取消</el-button>
      <el-button size="small" type="primary" @click="confirmHandle">确定</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { getnewAddwxxm, getModelLabourCode, getPrimaryGroupName, getSubGroupName, searchRepairType } from '@/api/repair/repair/activitesManage';
import { selectRepairProjectPart, findAllProject, getStroageList, getVehicleSeries } from '@/api/repair/repairBusiness/repairPackage';
import { findStorageCode } from '@/api/repair/basicParameters';
export default {
  name: 'addwxxm',
  mixins: [dictionary],
  props: ['series', 'seriesName'],
  data() {
    // this.twoTable = null;
    return {
      columns: this.createTableColumns(),
      topFilterList: this.createFormList(),
      fetchParams: { SERIES: this.series, xhrAbort: false },
      visiblenewWxxm: false,
      fetchApi: findAllProject,
      datasourceTablesecond: [],
      tablelistfirst: [],
      list: [] // 定义接收维修类型下拉框集合
    };
  },
  created() {},
  mounted() {
    // this.getModelLabourCode();
  },
  methods: {
    onRowSelectChange(val) {
      this.tablelistfirst = val;
    },
    // 点击确定进行添加
    async confirmHandle() {
      if (this.tablelistfirst.length == 0) {
        return this.$notify.warning({ title: '提示信息', message: '至少选择一条维修项目!' });
      }

      this.$emit('change', [...this.tablelistfirst]);
    },
    changeHandle(val) {
      let list = _.cloneDeep(val);
      list.modelLabourCode = this.series;
      this.fetchParams = Object.assign({}, { SERIES: this.series }, val);
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.$refs.table.$refs.pageTable.EXECUTE_RESET_HEIGHT();
      });
    },
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '维修项目代码',
          fieldName: 'labourCode',
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '维修项目名称',
          fieldName: 'labourName',
          placeholder: '请输入'
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '维修项目代码',
          dataIndex: 'LABOUR_CODE',
          sorter: true
        },
        {
          title: '维修项目名称',
          dataIndex: 'LABOUR_NAME',
          sorter: true
        },
        {
          title: '车系',
          dataIndex: 'SERIES_NAME',
          sorter: true
        },
        {
          title: '车型',
          dataIndex: 'MODEL_NAME',
          sorter: true
        },
        // {
        //   title: '项目维修类型',
        //   dataIndex: 'REPAIR_TYPE_NAME',
        //   sorter: true
        // },
        {
          title: '标准工时',
          dataIndex: 'STD_LABOUR_HOUR',
          sorter: true
        }
      ];
    },

    closeDialog() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped lang="less"></style>
